var findContinuousSequence = function(target) {
  if(target === 1) return [1]
  let arr = []
  let res = []
  for(let i=1; i<target; ++i){
      arr.push(i)
  }
  let left=1, right=2
  while(left<right && left<target && right<target){
      sum = (left+right)*(right-left+1)/2
      if(sum < target){
          right++
      } else if(sum > target) {
          left++
      } else {
          res.push(arr.slice(left-1, right))
          left++
          right++
      }
  }
  return res
};

var findContinuousSequence = function (target) {
  // 滑动窗口的左右边界（滑动窗口是左闭右开区间）
  let left = 1,
    right = 1;
  let midVal = target >> 1;
  // 滑动窗口中数字的和;
  let sum = 0;
  let res = [];
  while (left <= midVal) {
    if (sum < target) {
      // 窗口右边扩张
      sum += right;
      right++;
    } else if (sum > target) {
      // 窗口左边收缩
      sum -= left;
      left++;
    } else {
      let arr = [];
      for (let i = left; i < right; i++) {
        arr.push(i);
      }
      res.push(arr);
      sum -= left;
      left++;
    }
  }
  return res;
};


